#!/bin/bash

master_count=$1
woker_count=$2
ip_prefix=$3
ip_postfix=$4

echo -e "\n\n===========更新/etc/hosts=========== "
for ((i=1; i<=$master_count; i++)); do
    echo "${ip_prefix}.$((ip_postfix-1+i))  k3smaster$i" >>/etc/hosts
done

for ((i=1; i<=$woker_count; i++)); do
    echo "${ip_prefix}.$((ip_postfix+master_count-1+i))  k3sagent$i" >>/etc/hosts
done
echo "/etc/hosts >>>>"
cat /etc/hosts